import numpy as np
import os
import pathlib

src_data_root = pathlib.Path(r'F:\AIOPS\移动研究院\code\label-tool-cyp\data\移动_txt_200')
dst_data_root = pathlib.Path(r'F:\AIOPS\移动研究院\code\label-tool-cyp\data\移动_200')

txt_list = os.listdir(str(src_data_root))
for txt_file in txt_list:
    data = np.loadtxt(src_data_root / txt_file, delimiter=',')
    ts = np.linspace(start=0, stop=0+15*60*data.shape[0], num=data.shape[0])
    value = data
    # 归一化
    for i in range(value.shape[1]):
        if np.max(value[:, i]) != np.min(value[:, i]):
            value[:, i] = (value[:, i] - np.min(value[:, i])) / (np.max(value[:, i]) - np.min(value[:, i]))
        else:
            value[:, i] = 0
    np.savez(dst_data_root / txt_file.replace('txt', 'npz'), value=value, timestamp=ts)